#ifndef CIOPS_OP_EXTRUDE_H
#define CIOPS_OP_EXTRUDE_H

#include "Operation.h"
#include "../Core/Matrix.h"

namespace CIOps {
    /**
     * This class represents the operation of translation of primitives
     **/
    class OP_Extrude : public Operation {    

    public:            
        OP_Extrude (std::vector<CIView::View*>& v);     //Constructor
        virtual ~OP_Extrude();                          //Destructor

    protected:
        CICore::Point click;                                        //The mouse click coordinates (In world coordinates)
        CICore::Vector3D drag;                                      //The mouse drag values (In world coordinates)

        CICore::Matrix translationMatrix;                           //The matrix used to define the translation transformation
        CICore::Matrix inverseMatrix;                               //The inverse matrix used to undo the translation transformation

        std::vector<CIGeom::Geometry*> newGeometries;               //The geometries after extrusion
        std::vector<CIGeom::Geometry*> oldGeometries;               //The geometries before extrusion

        std::vector<int> oldVertexSize;                             //A vector to store the number of vertices of the geometries before extrusion
        std::vector<int> oldFaceSize;                               //A vector to store the number of faces of the geometries before extrusion

        CIGeom::Geometry* geometry;                                 //The geometry currently extruded
        std::map<CICore::Vertex*,CICore::Vertex*> clone;            //An hash table to keep reference to the clone of each extruded vertex
        std::map<CICore::Vertex*,bool> inserted;                    //An hash table to keep reference to the new vertices inserted in the geometry
                                
        std::map<CICore::Vertex*,std::map<CICore::Vertex*, bool> > infoEdgeSharing;

        void ExtrudeSelected();
        void Extrude (CICore::Face* face);
        void AddFace (CICore::Vertex* v1, CICore::Vertex* v2, CICore::Vertex* v3);

    public:            
        //Utility Methods
        virtual int Exec();         //Method called to execute directly the operation
        virtual void Undo();        //Method called to undo the operation
        virtual void Redo();        //Method called to redo the operation

        virtual void MousePressEvent (CIView::View* view, QMouseEvent* e);        //Mouse Pressed event handler
        virtual void MouseReleaseEvent (CIView::View* view, QMouseEvent* e);      //Mouse Released event handler
        virtual void MouseMoveEvent (CIView::View* view, QMouseEvent* e);         //Mouse Moved event handler
        virtual void WheelEvent (CIView::View* view, QWheelEvent* e);             //Wheel event handler
    };
}

#endif /* CIOPS_OP_EXTRUDE_H */
